﻿using System;
using Autodesk.Revit.DB;
using YArchitech.Revit;

namespace FetchDataCompare
{
	internal class GeoWallStruct : GeoObjectStructBase, IGeoObjectStruct
	{
		public override string GetElementAttribute()
		{
			string elementAttribute = base.GetElementAttribute();
			this.GetExtendAttribute(ref elementAttribute);
			return elementAttribute;
		}

		public void GetExtendAttribute(ref string attr)
		{
			this.GetStartAndEndPoint(ref attr);
			this.GetTopAndBottomLevel(ref attr);
			this.GetWallThickness(ref attr);
		}

		private void GetStartAndEndPoint(ref string attr)
		{
			Wall wall = base.UseElement as Wall;
			if (wall == null)
			{
				attr = (attr ?? "");
				return;
			}
			LocationCurve locationCurve = wall.Location as LocationCurve;
			base.GetStartAndEndPoint(locationCurve.Curve, ref attr);
		}

		private void GetTopAndBottomLevel(ref string attr)
		{
			Wall wall = base.UseElement as Wall;
			if (wall == null)
			{
				attr = (attr ?? "");
				return;
			}
			ElementId elementId = wall.GetParameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsElementId();
			Level level = base.UseDoc.GetElement(elementId) as Level;
			double num = wall.GetParameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble();
			string str = (level.Elevation + num).ToString("f2");
			attr = attr + str + ";";
			ElementId elementId2 = wall.GetParameter(BuiltInParameter.WALL_HEIGHT_TYPE).AsElementId();
			Level level2 = base.UseDoc.GetElement(elementId2) as Level;
			double num2 = wall.GetParameter(BuiltInParameter.WALL_TOP_OFFSET).AsDouble();
			string str2 = (level2.Elevation + num2).ToString("f2");
			attr = attr + str2 + ";";
		}

		private void GetWallThickness(ref string attr)
		{
			Wall wall = base.UseElement as Wall;
			if (wall == null)
			{
				attr = (attr ?? "");
				return;
			}
			string str = wall.WallType.GetParameter(BuiltInParameter.WALL_ATTR_WIDTH_PARAM).AsDouble().ToString("f2");
			attr = attr + str + ";";
		}
	}
}
